const { get_file_list, get_full_path } = require("../utils/file_tool");
const { BaseCommand } = require("./base");

class MergeFileCommand extends BaseCommand {
    async execute() {
        const splitFile = require("split-file");
        let { src, dst } = this.selfData;
        src = get_file_list(src);
        dst = get_full_path(dst);
        const names = await new Promise((resolve, reject) => {
            splitFile
                .mergeFiles(src, dst)
                .then((names) => {
                    resolve(names);
                })
                .catch((err) => {
                    reject(err);
                });
        });
        return names;
    }
}

module.exports = {
    MergeFileCommand,
};
